package com.github.postsanf.yinian.fragment;

import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.AbsListView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.github.postsanf.yinian.BaseFragment;
import com.github.postsanf.yinian.R;
import com.github.postsanf.yinian.adapter.PicWallTimeAdapter;
import com.github.postsanf.yinian.bean.ShowPicWallTime;
import com.github.postsanf.yinian.bean.ShowPicWallTimeList;
import com.github.postsanf.yinian.bean.YNNativeImage;
import com.github.postsanf.yinian.constants.ACTIONs;
import com.github.postsanf.yinian.constants.CommonConstants;
import com.github.postsanf.yinian.utils.UIHelper;
import com.github.postsanf.yinian.nativestick.StickyGridHeadersGridView;
import com.github.postsanf.yinian.utils.WrapContentGridLayoutManager;
import com.github.postsanf.yinian.utils.YNNativeComparator;
import com.github.postsanf.yinian.ynlist.YNRecyclerViewAdapter;
import com.litesuits.http.exception.HttpException;
import com.litesuits.http.listener.HttpListener;
import com.litesuits.http.request.StringRequest;
import com.litesuits.http.request.param.HttpMethods;
import com.litesuits.http.response.Response;
import com.umeng.analytics.MobclickAgent;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;

public class AlbumWallFragment extends BaseFragment {
    private View view;                       // 上下文视图
    //    private RecyclerView rv_home_album;              // 列表视图
    private ImageView wall_switch;
    private RelativeLayout rl_null;
    //    private AlbumWallAdapter2 mAdapter;                   // 适配器
//    private LinkedList<YNPhoto> mPhotoDatas;                // 照片墙数据
    private boolean isLoadingMore;
    private boolean isBottom;
    private WrapContentGridLayoutManager mGridLayoutManager;
    private YNRecyclerViewAdapter mYNRecyclerViewAdapter;
    private RelativeLayout rl_lead;
    private StickyGridHeadersGridView mGridView;
    //    private ProgressDialog mProgressDialog;
    private List<YNNativeImage> mNativeImageList = new ArrayList<>();
    private List<YNNativeImage> mNativeImageListMon = new ArrayList<>();
    private Map<String, Integer> sectionMap = new HashMap<>();
    private static int section = 1;
    private boolean dayTime = true;
    private PicWallTimeAdapter mGridAdapter;
    private boolean isLoading = false;
    private String dateMore;
    private String showMode;
    private Handler handler = new Handler();
    private ImageView iv;
    private ImageView iv_no_pic;
    private boolean walldaymouth = false;
    private Context mContext;

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        registerBoradcastReceiver();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//        mPhotoDatas = new LinkedList<>();
//        noticeServiceInit();
        mContext = getActivity();
        initView();
        return view;
    }

    private void initWallDAY() {
        dayTime = true;
        showMode = "day";
//                    rv_home_album.setVisibility(View.GONE);
        wall_switch.setImageResource(R.drawable.photowall_switchicon_day);
        mGridView.setVisibility(View.VISIBLE);
        mGridView.setNumColumns(3);
        showTimePhoto("initialize", null, "day", true);
    }

    private void initWallMOUTH() {
        dayTime = false;
        showMode = "month";
//                    rv_home_album.setVisibility(View.GONE);
        wall_switch.setImageResource(R.drawable.photowall_switchicon_mouth);
        mGridView.setVisibility(View.VISIBLE);
        mGridView.setNumColumns(4);
        showTimePhoto("initialize", null, "month", false);
    }


    private void initView() {
        view = View.inflate(mContext, R.layout.yn_fragment_album, null);
//        rv_home_album = (RecyclerView) view.findViewById(R.id.rv_home_album);
//        rv_home_album.setItemAnimator(new ScaleInAnimator(new OvershootInterpolator(1f)));
//        rv_home_album.getItemAnimator().setAddDuration(500);
//        rv_home_album.getItemAnimator().setRemoveDuration(500);
//        rv_home_album.getItemAnimator().setMoveDuration(500);
//        rv_home_album.getItemAnimator().setChangeDuration(500);
        mGridView = ((StickyGridHeadersGridView) view.findViewById(R.id.gv_album_gridView));
        rl_null = (RelativeLayout) view.findViewById(R.id.rl_null);
        wall_switch = (ImageView) view.findViewById(R.id.wall_switch);
        wall_switch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!walldaymouth) {
                    walldaymouth = true;
                    initWallDAY();
                } else {
                    walldaymouth = false;
                    initWallMOUTH();
                }
                if (ifTopShow) {
                    new AlertDialog.Builder(mContext).setMessage("上传照片以后就能正常使用了")
                            .setPositiveButton(R.string.yn_app_ok, new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int whichButton) {
                                }
                            }).show();
                }
                Intent statintentbtnmenu = new Intent(ACTIONs.record);
                statintentbtnmenu.putExtra("key", "照片墙切换排布_4");
                statintentbtnmenu.putExtra("value", 1);
                mContext.sendBroadcast(statintentbtnmenu);
            }
        });
        rl_lead = ((RelativeLayout) view.findViewById(R.id.rl_lead));
        rl_lead.setVisibility(View.VISIBLE);
        iv = ((ImageView) view.findViewById(R.id.iv));
        iv_no_pic = ((ImageView) view.findViewById(R.id.iv_no_pic));
//        mAdapter = new AlbumWallAdapter2(getActivity(), mPhotoDatas);
//        rv_home_album.setHasFixedSize(true);
//        SpacesItemDecoration decoration = new SpacesItemDecoration(3);
//        rv_home_album.addItemDecoration(decoration);
//        mYNRecyclerViewAdapter = new YNRecyclerViewAdapter(mAdapter);
//        rv_home_album.setAdapter(mYNRecyclerViewAdapter);
        //设置布局管理器
//        mGridLayoutManager = new WrapContentGridLayoutManager(getActivity(), 3);
//        mGridLayoutManager.setSpanSizeLookup(new HeaderSpanSizeLookup((YNRecyclerViewAdapter) rv_home_album.getAdapter(), mGridLayoutManager.getSpanCount()));
//        rv_home_album.setLayoutManager(mGridLayoutManager);
//        rv_home_album.addOnScrollListener(new EndlessRecyclerOnScrollListener() {
//            @Override
//            public void onLoadNextPage(View view) {
//                super.onLoadNextPage(view);
//                // 已经到底，返回
//                if (isBottom) {
//                    return;
//                }
//                // 加载中，返回
//                LoadingFooter.State state = RecyclerViewStateUtils.getFooterViewState(rv_home_album);
//                if (state == LoadingFooter.State.Loading) {
//                    return;
//                }
//                // 加载下一页
//                RecyclerViewStateUtils.setFooterViewState(getActivity(), rv_home_album, 30, LoadingFooter.State.Loading, null);
//                rv_home_album.postDelayed(new Runnable() {
//                    @Override
//                    public void run() {
//                        loadStatus(false, CommonConstants.YNS_SIGN_LOAD);
//                    }
//                }, 1000);
//            }
//        });
//        noticeServiceInit();
        mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                //第一个条目加上屏幕内可见条目等于总条目说明已经到底了，加载下一页
                if (totalItemCount > 18 && firstVisibleItem + visibleItemCount == totalItemCount) {
                    //是否正在刷新
                    if (isLoading) {
//                        Toast.makeText(getActivity(),"正在刷新中...",Toast.LENGTH_SHORT).show();
                        return;
                    }
                    showTimePhoto("loading", dateMore, showMode, dayTime);
                    isLoading = true;
                }
            }
        });
        initWallMOUTH();
    }

//    private void loadStatus(boolean isTop, String type) {
//        Log.d("yuhao", "loadStatus: ");
//        // 通知后台加载数据
//        Intent mIntent = new Intent(getActivity(), AlbumContentService.class);
//        mIntent.setAction(ACTIONs.actionAlbumWall);
//        mIntent.putExtra(ACTIONs.aNeedType, type);
//        mIntent.putExtra(ACTIONs.aGroupId, application.getCurGid());
//        mIntent.putExtra(ACTIONs.aLoadId, mAdapter.getIdByDirection(isTop));
//        getActivity().startService(mIntent);
//    }

    // 更新照片墙
//    private void updateView(List<YNPhoto> photoList, String direction) {
//        switch (direction) {
//            case ACTIONs.aAddTop:
//                mAdapter.addItemsFromTop(photoList);
////                rv_home_album.scrollToPosition(0);
//                break;
//            case ACTIONs.aAddBottom:
//                mAdapter.addItemsFromBottom(photoList);
//                if (photoList.size() == 0) {
//                    isBottom = true;
//                    RecyclerViewStateUtils.setFooterViewState(getActivity(), rv_home_album, 30, LoadingFooter.State.TheEnd, null);
//                } else {
//                    RecyclerViewStateUtils.setFooterViewState(rv_home_album, LoadingFooter.State.Normal);
//                }
//                break;
//        }
//        isLoadingMore = false;
//    }

    boolean first = true;
    // 分析并执行动作
    BroadcastReceiver mWallBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            switch (action) {
                //加载照片墙数据
//                case ACTIONs.actionWallUpdate:
//                    List<YNPhoto> photoList = (List<YNPhoto>) intent.getSerializableExtra(ACTIONs.aAddData);
//                    if (photoList != null && photoList.size() > 0) {
//                        Intent intentShare = new Intent(ACTIONs.firstPic);
//                        intentShare.putExtra("firstUrl", photoList.get(0).getThumbnail());
//                        getActivity().sendBroadcast(intentShare);
//                    } else {
//                        Intent intentShare2 = new Intent(ACTIONs.firstPic);
//                        intentShare2.putExtra("firstUrl", "");
//                        getActivity().sendBroadcast(intentShare2);
//                    }
//                    if (first) {
//                        if (photoList == null || photoList.size() == 0) {
//                            ImageLoader.getInstance().displayImage("drawable://" + R.drawable.zpkby_tupian, iv);
//                            ImageLoader.getInstance().displayImage("drawable://" + R.drawable.zpkby_wenzi, iv_no_pic);
//                            rl_lead.setVisibility(View.VISIBLE);
//                        } else {
//                            first = false;
//                            rl_lead.setVisibility(View.GONE);
//                        }
//                    }
//                    String direction = intent.getStringExtra(ACTIONs.aAddDirection);
////                    updateView(photoList, direction);
//                    photoList.clear();
//                    break;
//                case ACTIONs.actionSinglePhoto:
//                    String PhotoUrl = intent.getStringExtra(ACTIONs.PhotoUrl);
//                    for (int i = 0; i < mPhotoDatas.size(); i++) {
//                        if (PhotoUrl != null && PhotoUrl.equals(mPhotoDatas.get(i).getUrl())) {
//                            mPhotoDatas.remove(i);
//                            mAdapter.notifyItemRemoved(i);
//                            break;
//                        }
//                    }
//                    break;
                case ACTIONs.actionGridWallUpdate:
                    Log.i("xjs", "actionGridWallUpdate==>");
                    if (!walldaymouth) {
//                        getActivity().sendBroadcast(new Intent(ACTIONs.day));
                        dayTime = true;
                        showMode = "day";
//                        rv_home_album.setVisibility(View.GONE);
                        mGridView.setVisibility(View.VISIBLE);
                        mGridView.setNumColumns(3);
                        showTimePhoto("initialize", null, "day", true);
                    } else {
                        dayTime = false;
                        showMode = "month";
//                        rv_home_album.setVisibility(View.GONE);
                        mGridView.setVisibility(View.VISIBLE);
                        mGridView.setNumColumns(4);
                        showTimePhoto("initialize", null, "month", false);
                    }
                    break;
//                case ACTIONs.actionDeleteList:
//                    loadStatus(true, CommonConstants.YNS_SIGN_REFRESH);
//                    break;
                case ACTIONs.day:
                    Log.i("xjs", "ACTIONs.day");
                    dayTime = true;
                    showMode = "day";
//                    rv_home_album.setVisibility(View.GONE);
                    mGridView.setVisibility(View.VISIBLE);
                    mGridView.setNumColumns(3);
                    showTimePhoto("initialize", null, "day", true);
                    break;
                case ACTIONs.month:
                    Log.i("xjs", "ACTIONs.month");
                    dayTime = false;
                    showMode = "month";
//                    rv_home_album.setVisibility(View.GONE);
                    mGridView.setVisibility(View.VISIBLE);
                    mGridView.setNumColumns(4);
                    showTimePhoto("initialize", null, "month", false);
                    break;
                case ACTIONs.all:
//                    mGridView.setVisibility(View.GONE);
//                    rv_home_album.setVisibility(View.VISIBLE);
//                    noticeServiceInit();
                    break;
                case ACTIONs.switchheightbig:
                    boolean bb = intent.getBooleanExtra("btnleftright", false);
                    if (bb) {
                        Animation translateAnimation = new TranslateAnimation(0, 0, UIHelper.dip2px(getActivity(), 100), 0);
                        translateAnimation.setDuration(300);
                        wall_switch.startAnimation(translateAnimation);
                    }
                    RelativeLayout.LayoutParams rlpb = (RelativeLayout.LayoutParams) wall_switch.getLayoutParams();
                    rlpb.setMargins(0, 0, UIHelper.dip2px(getActivity(), 15), UIHelper.dip2px(getActivity(), 135));
                    wall_switch.setLayoutParams(rlpb);
                    break;
                case ACTIONs.switchheightsmall:
                    boolean bb2 = intent.getBooleanExtra("btnleftright", false);
                    if (bb2) {
                        Animation translateAnimation2 = new TranslateAnimation(0, 0, 0, UIHelper.dip2px(getActivity(), 100));
                        translateAnimation2.setDuration(300);
                        wall_switch.startAnimation(translateAnimation2);
                        translateAnimation2.setAnimationListener(new Animation.AnimationListener() {
                            @Override
                            public void onAnimationStart(Animation animation) {

                            }

                            @Override
                            public void onAnimationEnd(Animation animation) {
                                mContext.sendBroadcast(new Intent(ACTIONs.wallbuttonssmall));
                            }

                            @Override
                            public void onAnimationRepeat(Animation animation) {

                            }
                        });
                    } else {
                        RelativeLayout.LayoutParams rlps = (RelativeLayout.LayoutParams) wall_switch.getLayoutParams();
                        rlps.setMargins(0, 0, UIHelper.dip2px(getActivity(), 15), UIHelper.dip2px(getActivity(), 35));
                        wall_switch.setLayoutParams(rlps);
                    }
                    break;
                case ACTIONs.wallbuttonssmall:
                    RelativeLayout.LayoutParams rlps = (RelativeLayout.LayoutParams) wall_switch.getLayoutParams();
                    rlps.setMargins(0, 0, UIHelper.dip2px(getActivity(), 15), UIHelper.dip2px(getActivity(), 35));
                    wall_switch.setLayoutParams(rlps);
                    break;
            }
        }
    };

//    public ShowPicWallTimeList getFotosList()
//            throws Exception {
//        FotosList list = null;
//        String key = "fotoslist_" + pageIndex + "_" + FOTO_PAGE_SIZE;
//        if (isNetworkConnected() && (!isReadDataCache(key) || isRefresh)) {
//            list = ApiClient.getInstance().getFotosListForJson(this,
//                    pageIndex + 1);
//            if (list != null && pageIndex == 0) {
//                Notice notice = list.getNotice();
//                list.setNotice(null);
//                list.setCacheKey(key);
//                saveObject(list, key);
//                list.setNotice(notice);
//            }
//        } else {
//            list = (FotosList) readObject(key);
//            if (list == null)
//                list = new FotosList();
//        }
//        return list;
//    }

    boolean ifTopShow = false;

    // 按时间显示照片墙
    public void showTimePhoto(final String type, final String date, String mode, final boolean dayTime) {
        Log.d("yuhao", "showTimePhoto: ");
        if (type.equals("loading")) {
            Toast.makeText(mContext, "正在加载下一页...", Toast.LENGTH_SHORT).show();
        } else {
//            Toast.makeText(getActivity(), "加载中...", Toast.LENGTH_SHORT).show();
//            mProgressDialog = ProgressDialog.show(getActivity(), "正在加载中...", "");
            dismissDialog();
        }
        String urlsto = getString(R.string.BASE_URL) + getString(R.string.ynShowPhotoWallByDayOrMonth);
        LinkedHashMap<String, String> mParam = new LinkedHashMap<>();
        mParam.put(CommonConstants.YNS_GROUP_ID, application.getCurGid() + "");
        if (date != null) {
            mParam.put(CommonConstants.DATE, date);
        }
        mParam.put(CommonConstants.YNS_PIC_MODE, mode);
        mParam.put(CommonConstants.YNS_TYPE, type);
        mParam.put(CommonConstants.YNS_CHANELSOURCE, "app");
        StringRequest req = new StringRequest(urlsto)
                .setMethod(HttpMethods.Post)
                .setParamMap(mParam)
                .setHttpListener(new HttpListener<String>(true, false, true) {
                    @Override
                    public void onSuccess(String s, Response<String> response) {
                        ShowPicWallTime showPicWallTime = gson.fromJson(s, ShowPicWallTime.class);
                        if (TextUtils.equals(showPicWallTime.getMsg(), "success")) {
                            List<ShowPicWallTime.DataBean> data = showPicWallTime.getData();
                            ShowPicWallTimeList showPicWallTimeList = new ShowPicWallTimeList();
                            showPicWallTimeList.getSpwtDataBean().addAll(data);
//                            Log.i("xjs", "datassss===>" + data.size());
                            if (data.size() == 0 && type.equals("loading")) {
                                Toast.makeText(mContext, "已经到底啦...", Toast.LENGTH_SHORT).show();
                                return;
                            }
//                            else if (data.size() == 0) {
//                                Log.i("xjs", "000000");
//                                ifTopShow = true;
//                                rl_null.setVisibility(View.VISIBLE);
//                                mGridView.setVisibility(View.GONE);
////                                mNativeImageList.clear();
//                                return;
//                            }
                            else if (type.equals("initialize")) {
                                Log.i("xjs", "initialize");
                                mNativeImageList.clear();
                                if (data.size() == 0) {
                                    ifTopShow = true;
                                    rl_null.setVisibility(View.VISIBLE);
                                    mGridView.setVisibility(View.GONE);
                                } else {
                                    ifTopShow = false;
                                    Log.i("xjs", "data不为零");
                                    rl_null.setVisibility(View.GONE);
                                    mGridView.setVisibility(View.VISIBLE);
                                }
                            }
                            if (data.size() > 0) {
                                ifTopShow = false;
                                for (int i = 0; i < data.size(); i++) {
                                    String upLoadDate = data.get(i).getEuploadtime();
                                    List<ShowPicWallTime.DataBean.PictureBean> pictureList = data.get(i).getPicture();
                                    for (int j = 0; j < pictureList.size(); j++) {
                                        String thumbnail = pictureList.get(j).getThumbnail();
                                        String path = pictureList.get(j).getUrl();
                                        YNNativeImage mNativeItem = new YNNativeImage();
                                        mNativeItem.setPath(path);
                                        mNativeItem.setTime(upLoadDate);
                                        mNativeItem.setThumbnail(thumbnail);
                                        mNativeImageList.add(mNativeItem);
                                    }
                                    if (i == data.size() - 1) {
                                        dateMore = data.get(i).getEuploadtime();
                                    }
                                }
//                            Log.d("yuhao", "dateMore="+dateMore);
                                Collections.sort(mNativeImageList, new YNNativeComparator());
                                for (ListIterator<YNNativeImage> it = mNativeImageList.listIterator(); it.hasNext(); ) {
                                    YNNativeImage mNativeItem = it.next();
                                    String ym = mNativeItem.getTime();
                                    if (!sectionMap.containsKey(ym)) {
                                        mNativeItem.setSection(section);
                                        sectionMap.put(ym, section);
                                        section++;
                                    } else {
                                        mNativeItem.setSection(sectionMap.get(ym));
                                    }
                                }
                                if (mNativeImageList.size() != 0 && type.equals("initialize")) {
                                    mGridAdapter = new PicWallTimeAdapter(mContext, mNativeImageList, dayTime);
                                    mGridView.setAdapter(mGridAdapter);
                                } else if (mNativeImageList.size() != 0 && type.equals("loading")) {
                                    mGridAdapter.setData(mNativeImageList, dayTime);
                                    mGridAdapter.notifyDataSetChanged();
                                }
                            }
                            //二维码图片分享照片墙第一张图片
                            if (data != null && data.size() > 0 && data.get(0) != null) {
                                Intent intent = new Intent(ACTIONs.firstPic);
                                if (data.get(0).getPicture().size() > 0) {
                                    intent.putExtra("firstUrl", data.get(0).getPicture().get(0).getThumbnail());
                                } else {
                                    intent.putExtra("firstUrl", "");
                                }
                                application.sendBroadcast(intent);
                            } else {
                                Intent intent2 = new Intent(ACTIONs.firstPic);
                                intent2.putExtra("firstUrl", "");
                                application.sendBroadcast(intent2);
                            }
                        } else {
                            Log.d("yuhao", "UploadToYiNian=" + "fail");
                        }
                        isLoading = false;
//                        mProgressDialog.dismiss();
                        handler.removeCallbacks(mRunnable);
                        if (type.equals("loading")) {
                            Toast.makeText(mContext, "加载完成啦......", Toast.LENGTH_SHORT).show();
                        }
                    }

                    @Override
                    public void onFailure(HttpException e, Response<String> response) {
                        Log.i("xjs", "onFailure===>");
//                        mProgressDialog.dismiss();
                        handler.removeCallbacks(mRunnable);
                        isLoading = false;
                        Toast.makeText(mContext, CommonConstants.YN_NET_LINK, Toast.LENGTH_SHORT).show();
                    }
                });
        liteHttp.executeAsync(req);
    }

    private void dismissDialog() {
        handler.postDelayed(mRunnable, 1000 * 3);
    }

    Runnable mRunnable = new Runnable() {
        @Override
        public void run() {
//            mProgressDialog.dismiss();
            Toast.makeText(mContext, "无数据，请重试...", Toast.LENGTH_SHORT).show();
        }
    };

    // 注册接收者
    private void registerBoradcastReceiver() {
        IntentFilter myIntentFilter = new IntentFilter();
        myIntentFilter.addAction(ACTIONs.actionWallUpdate);
        myIntentFilter.addAction(ACTIONs.actionGridWallUpdate);
        myIntentFilter.addAction(ACTIONs.actionSinglePhoto);
        myIntentFilter.addAction(ACTIONs.actionDeleteList);
        myIntentFilter.addAction(ACTIONs.day);
        myIntentFilter.addAction(ACTIONs.month);
        myIntentFilter.addAction(ACTIONs.all);
        myIntentFilter.addAction(ACTIONs.switchheightbig);
        myIntentFilter.addAction(ACTIONs.switchheightsmall);
        myIntentFilter.addAction(ACTIONs.wallbuttonssmall);
        getActivity().registerReceiver(mWallBroadcastReceiver, myIntentFilter);
    }

    // 通知后台加载数据
//    private void noticeServiceInit() {
//        if (getActivity() == null) {
//            return;
//        }
//        Intent mIntent = new Intent(getActivity(), AlbumContentService.class);
//        mIntent.setAction(ACTIONs.actionAlbumWall);
//        mIntent.putExtra(ACTIONs.aGroupId, application.getCurGid());
//        mIntent.putExtra(ACTIONs.aNeedType, CommonConstants.YNS_SIGN_INITS);
//        mIntent.putExtra(ACTIONs.aLoadId, 0);
//        getActivity().startService(mIntent);
//    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        mContext.unregisterReceiver(mWallBroadcastReceiver);
    }

    // 友盟统计
    public void onResume() {
        super.onResume();
//        loadStatus(true,CommonConstants.YNS_SIGN_REFRESH);
        MobclickAgent.onPageStart("MainScreen");
    }

    public void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd("MainScreen");
    }
}